# This is a sample Python script.

# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.

import cv2 as cv
import numpy as np
import point


def resize_img(image, height=1800):
    h, w = image.shape[:2]
    pro = height / h
    s_w = int(w * pro)
    s_h = int(height)
    size = (s_w, s_h)
    img = cv.resize(image, size)
    return img, s_h, s_w, pro


# path = '/Users/wanggh/Desktop/a.jpeg'
path = '/Users/wanggh/Desktop/original.jpeg'
# path = '/Users/wanggh/Desktop/b.jpeg'

default_pro = 0.76
src = cv.imread(path)
# src, src_h, src_w, src_pro = resize_img(src)
gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv.cornerHarris(gray, 2, 3, 0.04)
# result用于标记角点，并不重要
dst = cv.dilate(dst, None)
# 最佳值的阈值，它可能因图像而异。
src[dst > 0.01 * dst.max()] = [0, 0, 255]
cv.imshow("test", src)
cv.waitKey(0)
cv.destroyAllWindows()
